import { Exclude } from 'class-transformer';
import {
  Column,
  DeleteDateColumn,
  PrimaryGeneratedColumn,
  VersionColumn,
} from 'typeorm';

// 基础实体
export class AppBaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  // 创建时间
  @Column({
    name: 'created_at',
    type: 'bigint',
  })
  createdAt: number;

  // 更新时间
  @Column({
    name: 'updated_at',
    type: 'bigint',
  })
  updatedAt: number;

  // 软删除时间
  @DeleteDateColumn({
    name: 'deleted_at',
  })
  @Exclude()
  deletedAt: Date;

  // 版本号
  @VersionColumn()
  @Exclude()
  version: number;
}
